import React, { Component } from 'react';
import './index.less';
import { promptBox, base } from 'nc-lightapp-front';

const { NCModal, NCButton } = base;
const { Header: NCModalHeader, Body: NCModalBody, Footer: NCModalFooter } = NCModal;

class StopModal extends Component {
	constructor(props) {
		super(props);
		this.getEditInitInfo = this.getEditInitInfo.bind(this);
		this.closeModal = this.closeModal.bind(this);
		this.beSure = this.beSure.bind(this);
	}

	getEditInitInfo() {
		const { form } = this.props;
		form.setFormStatus('ctrtoperatedlg', 'edit');
	}

	beSure() {
		const flag = this.props.form.isCheckNow('ctrtoperatedlg');
		if (!flag) return;
		//stopConConfirm.call(this)
		const { json } = this.props;
		promptBox({
			color: 'warning',
			title: json['cm6011-000036'], // 确认删除/* 国际化处理： 确认终止*/
			content: json['cm6011-000037'], // 是否删除这个报表，/* 国际化处理： 您所选人员的劳动合同即将终止，确实要终止劳动合同吗？*/
			beSureBtnClick: () => {
				this.props.beSure();
			}
		});
	}

	closeModal() {
		this.props.onClose && this.props.onClose();
	}

	render() {
		const { form, visible, json } = this.props;
		return (
			<NCModal
				show={visible}
				size="lg"
				onHide={this.closeModal}
				onEntered={this.getEditInitInfo}
				backdrop={'static'}
			>
				<NCModalHeader closeButton={true}>
					{json['cm6011-000038']}
					{/* 国际化处理： 合同终止*/}
				</NCModalHeader>
				<NCModalBody>{form.createForm('ctrtoperatedlg')}</NCModalBody>
				<NCModalFooter>
					<NCButton colors="primary" onClick={this.beSure}>
						{json['cm6011-000028']}
						{/* 国际化处理： 确认*/}
					</NCButton>
					<NCButton shape="border" onClick={this.closeModal}>
						{json['cm6011-000054']}
						{/* 国际化处理： 取消*/}
					</NCButton>
				</NCModalFooter>
			</NCModal>
		);
	}
}

export default StopModal;
